#include "StdAfx.h"
#include "TickCounter.h"

CTickCounter::CTickCounter(void)
{
	QueryPerformanceFrequency(&m_tickFrequency);
	QueryPerformanceCounter(&m_tickStart);
}

CTickCounter::~CTickCounter(void)
{
}

__int64 CTickCounter::GetTickCount(BOOL bReset)
{
	LARGE_INTEGER tickCur;
	QueryPerformanceCounter(&tickCur);

	__int64 nTickCount = (tickCur.QuadPart - m_tickStart.QuadPart);
	if(bReset)
	{
		m_tickStart = tickCur;
	}

	return nTickCount;
}

float CTickCounter::GetElapseMillisecond(BOOL bReset)
{
	__int64 nTickCount = GetTickCount(bReset);

	double dElapse = static_cast<double>(nTickCount) / static_cast<double>(m_tickFrequency.QuadPart)*1000.0;
	return static_cast<float>(dElapse);
}

